package com.bayihouse.model.vo;

import com.bayihouse.model.entity.House;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.text.SimpleDateFormat;


@AllArgsConstructor
@NoArgsConstructor
@Data
public class HouseVO implements Serializable {
    private static final long serialVersionUID = -7921366276047902700L;


    private Long id;

    /**
     * 楼的名称
     */
    private String name;

    /**
     * 探针数量
     */
    private Integer probeNum;

    /**
     * 该楼的其他详情
     */
    private String detail;

    /**
     * 所属小区
     */
    private Long communityId;

    private String createTime;


    public static HouseVO objToVo(House house) {
        HouseVO houseVO = new HouseVO();
        BeanUtils.copyProperties(house, houseVO);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String format = simpleDateFormat.format(house.getCreateTime());
        houseVO.setCreateTime(format);
        return houseVO;
    }


    public static House voToObj(HouseVO houseVO) {
        House house = new House();
        BeanUtils.copyProperties(houseVO, house);
        return house;
    }
}
